<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="utf-8"/>
	<title>订单留言列表</title>
	<link rel="stylesheet" type="text/css" th:href="@{/layui/css/layui.css}" media="all" />
	<link rel="stylesheet" type="text/css" th:href="@{/css/news.css}" media="all" />
</head>
<body class="childrenBody" style="width:1400px;">
	<blockquote class="layui-elem-quote news_search">
	<form id="searchForm" name="searchForm" class="layui-form" action="/orderMessage/orderMessage.html">
 		<input type="hidden" id="pageNum" name="pageNum" th:value="${page}?${page.pageNum}"/>
		  <div class="layui-form-item">
			<label class="layui-form-label">订单号:</label>
		    <div class="layui-input-inline">
		    	 <input  type="text" class="layui-input" name="orderNo" id="orderId"  th:value="${orderNo}?${orderNo}"/>
		    </div>
		    <button class="layui-btn search_btn"><i class="layui-icon">&#xe615;</i>查询</button>
<!--             <a class="layui-btn layui-btn-normal newsAdd_btn" id="add"><i class="layui-icon">&#xe608;</i>添加</a> -->
         </div>
	</form>
	</blockquote>
	<div class="layui-form news_list">
	  	<table class="layui-table">
		    <thead>
				<tr>
					<th>订单号</th>
					<th>留言内容</th>
					<th>留言视频</th>
					<th>留言图片</th>
					<th>创建时间</th>
					<th>操作</th>
				</tr> 
		    </thead>
		    <tbody class="news_content">
		  	  <th:block th:if="${not #lists.isEmpty(page.list)}">
			    	<tr th:each="item:${page.list}">
				    	<td  th:text="${item.orderNo}"></td>
				    	<td  th:text="${item.content}"></td>
				    	<td  th:text="${item.videoUrl}"></td>
				    	<td  th:text="${item.imageUrl}"></td>
				    	<td  th:text="${#dates.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
				    	<td>
                            <a th:data="${item.id}"  class="layui-btn layui-btn-mini product_info">查看</a>
						</td>
					</tr>
				</th:block>
		    </tbody>
		</table>
	</div>
	<div id="paged" align="right"></div>
	<script type="text/javascript" th:src="@{/layui/layui.js}"></script>
    <script type="text/javascript" th:src="@{/jquery/jquery-3.2.1.min.js}"></script>
	</body>
	<script th:inline="javascript">
         layui.use('laypage', function(){
        	  var laypage = layui.laypage;
        	  //执行一个laypage实例
        	  laypage.render({
        	    elem: 'paged', //注意，这里的 test1 是 ID，不用加 # 号
        	    curr: [[${page.pageNum}]],
        	    count: [[${page.total}]], //数据总数，从服务端得到
        	    layout: ['count', 'prev', 'page', 'next'],
                jump: function(obj, first){
                    //得到了当前页，用于向服务端请求对应数据
                    var curr = obj.curr;
                    $("#pageNum").val(curr);
                    if(!first) {
                        $("#searchForm").submit();
					}
                }
        	  });
        	});
        
        layui.use('layer', function(){
            var layer = layui.layer,$=layui.jquery;

            $(".shelves").bind("click",function () {
                var id = $(this).attr('data');
                layer.confirm('确定要上架吗?', {icon: 3, title:'提示'}, function(index){
                    $.post('/orderMessage/updateProductStatus.html', {id:id,status:1}, function(data){
                        location.reload();
                    });
                });
            });

            $(".offShelf").bind("click",function () {
                var id = $(this).attr('data');
                layer.confirm('确定要下架该产品吗?', {icon: 3, title:'提示'}, function(index){
                    $.post('/product/updateProductStatus.html', {id:id,status:4}, function(data){
                        location.reload();
                    });
                });
            });
            $(".sale").bind("click",function () {
                var id = $(this).attr('data');
                layer.confirm('确定要销售该产品吗?', {icon: 3, title:'提示'}, function(index){
                    $.post('/product/updateProductStatus.html', {id:id,status:2}, function(data){
                        location.reload();
                    });
                });
            });
            
            //删除
            $(".layui-btn-danger").bind("click",function() {
                var id = $(this).attr("data");
                layer.confirm('确定要删除吗?', {icon: 3, title:'提示'}, function(index){
                	  location.href="/orderMessage/orderMessageDel.html?id="+id;
                });
            });
            
            //查看
            $(".product_info").bind("click",function() {
                var id = $(this).attr("data");
                //Ajax获取
            	$.post('/orderMessage/orderMessageInfo.html', {id:id}, function(data){
            	  	layer.open({
            	  	  type: 1,
              		  title: '查看产品'
              		  ,area: ['1000px', '460px']
              		  ,shade: 0
              		  ,content: data
           			  ,yes: function(index, layero){
           				  layer.close(index);
           				}
              		}); 
            	}); 
            });

            //编辑
            $(".product_edit").bind("click",function() {
                var id = $(this).attr("data");
                //Ajax获取
            	form_html(id,'编辑产品');
            });

            //添加
            $("#add").bind("click",function() {
            	//Ajax获取
            	form_html("",'添加产品');
            });
            
             function form_html(id,title){
              	$.post('/orderMessage/orderMessageAdd.html', {id:id}, function(data){
            	  	layer.open({
            	  	  type: 1,
              		  title: title
              		  ,area: ['1000px', '460px']
              		  ,shade: 0
              		  ,content: data
           			  ,yes: function(index, layero){
           				  layer.close(index);
           				}
              		}); 
            	}); 
            };
        });


         layui.use('form', function(){
             var form = layui.form;
             form.render();
         });
	</script>
</html>